#include<bits/stdc++.h>
using namespace std;

#define rint register int
const int maxn = 2e5 + 5;
int n;
bool a[maxn], vis[maxn];

inline int read ()
{
	int x = 1, s = 0;
	char ch = getchar ();
	while (ch < '0' or ch > '9')
	{
		if (ch == '-')
			x = -1;
		ch = getchar ();
	}
	while (ch >= '0' and ch <= '9')
		s = s * 10 + ch - '0', ch = getchar ();
	return x * s;
}

int main ()
{
	freopen ("fruit.in", "r", stdin); freopen ("fruit.out", "w", stdout);
	n = read ();
	for (rint i (1); i <= n; ++i) 
		a[i] = read ();
	int cnt = n;
	a[0] = a[1] ^ 1;
	int lst = 0;
	while (cnt > 0)
	{
		lst = 0;
		for (rint i (1); i <= n; ++i)
		{
			if (vis[i]) continue;
			if (a[i] != a[lst] or !lst) 
			{
				vis[i] = 1;
				printf ("%d ", i);
				cnt -= 1;
			}
			lst = i;
		}
		printf ("\n");
	}
	return 0;
}
